import 'package:boss/ui/page/takeoutManagement/page/takeoutDetail/provider/takeout_detail_provider.dart';
import 'package:boss/ui/widget/center_title_app_bar.dart';
import 'package:boss/ui/widget/loader/loader.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:router/annotation.dart';

import 'widget/takeout_detail_browser.dart';

@RouterConfig(TakeoutDetailPage.pageName)
class TakeoutDetailPage extends StatefulWidget {
  static const pageName = '/TakeoutDetailPage';

  @Autowired()
  final String takeoutId;

  const TakeoutDetailPage({
    Key key,
    this.takeoutId,
  }) : super(key: key);

  @override
  _TakeoutDetailPageState createState() => _TakeoutDetailPageState();
}

class _TakeoutDetailPageState extends State<TakeoutDetailPage> {
  @override
  Widget build(BuildContext context) {
    return ChangeNotifierProvider(
      create: (_) => TakeoutDetailProvider(),
      child: Scaffold(
        appBar: CenterTitleAppBar(
          title: '订单详情',
        ),
        body: Builder(builder: (context) {
          return Loader(
            loadTask: () => Provider.of<TakeoutDetailProvider>(context, listen: false).queryTakeoutDetailById(widget.takeoutId),
            builder: (context) => TakeoutDetailBrowser(),
          );
        }),
      ),
    );
  }
}
